//
//  CustomSearchCell.m
//  MedicineBox
//
//  Created by dllo on 15/9/19.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "CustomSearchCell.h"
#import "CustomTap.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersion.h"
@interface CustomSearchCell ()

@property (nonatomic, retain) NSMutableDictionary *searchDic;

@property (nonatomic, retain) UIImageView *imageV1;
@property (nonatomic, retain) UILabel *titleLabel1;

@property (nonatomic, retain) UIImageView *imageV2;
@property (nonatomic, retain) UILabel *titleLabel2;

@property (nonatomic, retain) UIImageView *imageV3;
@property (nonatomic, retain) UILabel *titleLabel3;


@property (nonatomic, retain) CustomTap *tap1;
@property (nonatomic, retain) CustomTap *tap2;
@property (nonatomic, retain) CustomTap *tap3;
@property (nonatomic, retain) CustomTap *tap4;

@end
@implementation CustomSearchCell


- (void)dealloc
{
    
    [super dealloc];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatSubview];
        
    }
    return self;
}

- (void)creatSubview
{
    
    
    self.imageV1 = [[UIImageView alloc] initWithFrame:CGRectMake(25 , 2 , 50, 50)];
    _imageV1.userInteractionEnabled = YES;
    [self addSubview:_imageV1];
    [_imageV1 release];
    self.titleLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(_imageV1.frame.origin.x , _imageV1.frame.origin.y + _imageV1.frame.size.height + 3, _imageV1.frame.size.width, 20)];
    
    _titleLabel1.font = [UIFont systemFontOfSize:10];
    _titleLabel1.textAlignment = NSTextAlignmentCenter;
    _titleLabel1.nightTextColor = [UIColor whiteColor];
    [self addSubview:_titleLabel1];
    [_titleLabel1 release];
    
    self.tap1 = [[CustomTap alloc] initWithTarget:self action:@selector(tapAction:)];
    [_imageV1 addGestureRecognizer:_tap1];
    [_tap1 release];
    
    self.imageV2 = [[UIImageView alloc] initWithFrame:CGRectMake(_imageV1.frame.origin.x + _imageV1.frame.size.width + 20 , 2 , 50, 50)];
    _imageV2.userInteractionEnabled = YES;
    [self addSubview:_imageV2];
    [_imageV2 release];
    self.titleLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(_imageV2.frame.origin.x, _imageV2.frame.origin.y + _imageV2.frame.size.height + 3, _imageV2.frame.size.width, 20)];
    
    _titleLabel2.font = [UIFont systemFontOfSize:10];
    _titleLabel2.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_titleLabel2];
    _titleLabel2.nightTextColor = [UIColor whiteColor];
    [_titleLabel2 release];
    self.tap2 = [[CustomTap alloc] initWithTarget:self action:@selector(tapAction:)];
    [_imageV2 addGestureRecognizer:_tap2];
    [_tap2 release];
    
    self.imageV3 = [[UIImageView alloc] initWithFrame:CGRectMake(_imageV2.frame.origin.x + _imageV2.frame.size.width + 20 , 2 , 50, 50)];
    _imageV3.userInteractionEnabled = YES;
    [self addSubview:_imageV3];
    [_imageV3 release];
    self.titleLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(_imageV3.frame.origin.x, _imageV3.frame.origin.y + _imageV3.frame.size.height + 3, _imageV3.frame.size.width, 20)];
    
    _titleLabel3.font = [UIFont systemFontOfSize:10];
    _titleLabel3.textAlignment = NSTextAlignmentCenter;
    _titleLabel3.nightTextColor = [UIColor whiteColor];
    [self addSubview:_titleLabel3];
    [_titleLabel3 release];
    self.tap3 = [[CustomTap alloc] initWithTarget:self action:@selector(tapAction:)];
    [_imageV3 addGestureRecognizer:_tap3];
    [_tap3 release];
    
    
    
}


- (void)getSearContentWithDic:(NSDictionary *)dic1 dic2:(NSDictionary *)dic2 dic3:(NSDictionary *)dic3
{
    
    [_imageV1 sd_setImageWithURL:[NSURL URLWithString:[dic1 objectForKey:@"icon"]]];
    
    _titleLabel1.text = [dic1 objectForKey:@"name"];
    
    _tap1.dic = dic1;
    
    
    [_imageV2 sd_setImageWithURL:[NSURL URLWithString:[dic2 objectForKey:@"icon"]]];
    
    _titleLabel2.text = [dic2 objectForKey:@"name"];
    
    _tap2.dic = dic2;
    
    
    [_imageV3 sd_setImageWithURL:[NSURL URLWithString:[dic3 objectForKey:@"icon"]]];
    
    _titleLabel3.text = [dic3 objectForKey:@"name"];
    
    _tap3.dic = dic3;

    

}


- (void)tapAction:(CustomTap *)tap
{
    
    [(NSObject *)self.target performSelector:self.action withObject:tap.dic];
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
